package com.bbz.crawler.controller;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.plugins.Page;
import com.bbz.crawler.core.commen.model.CrawlerResultDetail;
import com.bbz.crawler.service.ICrawlerResultDetailService;
/**
 * <p>
 * CrawlerResultDetailController
 * </p>
 *
 * @author binbin.a.zhang123
 * @since 2018-05-29
 */
@RestController
@RequestMapping("/crawlerResultDetail")
public class CrawlerResultDetailController  {

    @Autowired
    private ICrawlerResultDetailService crawlerResultDetailService;

    /**
     * 跳转到添加页面CrawlerResultDetail
     */
    @RequestMapping("/addCrawlerResultDetail")
    public String crawlerResultDetailAdd() {
        return  "addCrawlerResultDetail.html";
    }

    /**
     * 跳转到编辑页面CrawlerResultDetail
     */
    @RequestMapping("/editCrawlerResultDetail/{crawlerResultDetailId}")
    public String editCrawlerResultDetail(@PathVariable Integer crawlerResultDetailId, ModelMap model) {
        CrawlerResultDetail crawlerResultDetail = crawlerResultDetailService.selectById(crawlerResultDetailId);
        model.addAttribute("item",crawlerResultDetail);
        return "editCrawlerResultDetail.html";
    }

    /**
     * 获取CrawlerResultDetail列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return crawlerResultDetailService.selectList(null);
    }

  	/**
     * 获取CrawlerResultDetail列表
     */
    @RequestMapping(value = "/list/page/{page}/size/{size}")
    @ResponseBody
    public Object listPage(@PathVariable Integer page, @PathVariable Integer size) {
        return crawlerResultDetailService.selectMapsPage(new Page<>(page, size), null);
    }
    
    /**
     * 新增CrawlerResultDetail
     */
    @RequestMapping(value = "/add")
    public Object add(CrawlerResultDetail crawlerResultDetail) {
        crawlerResultDetailService.insert(crawlerResultDetail);
        return null;
    }

    /**
     * 删除CrawlerResultDetail
     */
    @RequestMapping(value = "/delete")
    public Object delete(@RequestParam Integer crawlerResultDetailId) {
        crawlerResultDetailService.deleteById(crawlerResultDetailId);
        return null;
    }

    /**
     * 修改CrawlerResultDetail
     */
    @RequestMapping(value = "/update")
    public Object update(CrawlerResultDetail crawlerResultDetail) {
        crawlerResultDetailService.updateById(crawlerResultDetail);
        return null;
    }

    /**
     * CrawlerResultDetail详情
     */
    @RequestMapping(value = "/detail/{crawlerResultDetailId}")
    public Object detail(@PathVariable("crawlerResultDetailId") Integer crawlerResultDetailId) {
        return crawlerResultDetailService.selectById(crawlerResultDetailId);
    }
}
